set more off

use dataset_county, clear

gen D = D2016-D1990

xtile DQ = D if D > 0, nq(5)
replace DQ = 0 if DQ == .

forvalues i = 0(1)5 {
	su D if DQ == `i'
	if `i' == 0 local label`i' = string(r(max), "%20.0fc")
	if `i' > 0 local label`i' = string(r(min), "%20.0fc") + "-" + ///
		string(r(max), "%20.0fc")
}

#delimit;

spmap
	DQ
		using "dataset_coords_counties"
		,
			id(_id) 
			clmethod(unique)
			fcolor(Greys2)
			ocolor(
				white 
				white
				white
				white
				white
				white 
				white
				white
				white
				white	
				white
			)	
 			legend(
				order(
					2 "`label0'"
					3 "`label1'"
					4 "`label2'"
					5 "`label3'"
					6 "`label4'"
					7 "`label5'"
 			
				)
				size(huge)
				symysize(medium)
				symxsize(medium)
				rowgap(0)
				pos(7)
			)		
 
			;

#delimit cr

gr export "_output/figure2.png", replace
